using System;
using System.Collections.Generic;
using Common.Core.Caching;

namespace Common.Core.Caching
{
	internal class EntityCacheContainer : ICacheContainer<int>
	{
		private static readonly IDictionary<Type, object> caches = new Dictionary<Type, object>();

		public IEntityCache<EntityType, int> Get<EntityType>() where EntityType : class
		{
			if (!caches.ContainsKey(typeof(EntityType)))
			{
				caches.Add(typeof(EntityType), new EntityCache<EntityType, int>(Configuration.EntityCacheLength, true));
			}

			return caches[typeof(EntityType)] as IEntityCache<EntityType, int>;
		}
	}
}